package com.begood.leishi.fingerprinter;

/**
 * Created by leishi on 2017/12/1.
 */

public class FpError {

    public static String message(int code){
        switch (code){
            case -1: return "发送数据包失败";
            case -2: return "接收数据包失败";
            case -3: return "校验和错";
            case -4: return "缓冲区号超出范围或 flash 模板号无效" ;
            case -5: return "安全等级无效";
            case -6: return "生成指定文件失败" ;
            case -7: return "指定文件不存在" ;
            case -8: return "文件大小不合法" ;
            case -9: return "内存分配失败";
            case -10: return "指纹模块未开启";
            case 0: return "执行成功";
            case 1: return "数据包接收错误";
            case 2: return "传感器上没有手指";
            case 3: return "录入指纹图象失败" ;
            case 4: return "指纹太淡";
            case 5: return "指纹太糊";
            case 6: return "指纹太乱";
            case 7: return "指纹特征点太少";
            case 8: return "指纹不匹配";
            case 9: return "没搜索到指纹";
            case 10: return "特征合并失败";
            case 11: return "地址号超出指纹库范围" ;
            case 12: return "从指纹库读模板出错" ;
            case 13: return "上传特征失败";
            case 14: return "模块不能接收后续数据包" ;
            case 15: return "上传图象失败";
            case 16: return "删除模板失败";
            case 17: return "清空指纹库失败";
            case 18: return "不能进入休眠";
            case 19: return "口令不正确";
            case 20: return "系统复位失败";
            case 21: return "无效指纹图象";
            case 22: return "在线升级失败";
            case 23: return "残留或未移动";
            case 24: return "表示读写 FLASH 出错";
            case 25: return "未定义错误";
            case 26: return "无效寄存器号";
            case 27: return "寄存器设定内容错误号";
            case 28: return "记事本页码指定错误";
            case 29: return "端口操作失败";
            case 30: return "自动注册(enroll)失败";
            case 31: return "指纹库满";
            case 0xf0: return "有后续数据包的指令，正确接收后用 0xf0 应答" ;
            case 0xf1: return "有后续数据包的指令，命令包用 0xf1 应答";
            case 0xf2: return "表示烧写内部 FLASH 时，校验和错误";
            case 0xf3: return "表示烧写内部 FLASH 时，包标识错误";
            case 0xf4: return "表示烧写内部 FLASH 时，包长度错误";
            case 0xf5: return "表示烧写内部 FLASH 时，代码长度太长";
            case 0xf6: return "表示烧写内部 FLASH 时，烧写 FLASH 失败" ;
            case 0x20: return "空操作";
            case 0x21: return "超时错误";
            case 0x22: return "该指纹已经注册过";
            default: return "未知错误";
        }
    }
    //根据错误返回错误码
    public static int code(String message){
        for(int ret = -9;ret<=0x22;ret++){
            if(message.equals(message(ret))){
                return ret;
            }
        }
        return 0xffff;
    }
}
